﻿using System.Linq;

namespace Devbridge.IPolice.DataContracts
{
    /// <summary>
    /// Generic repository interface
    /// </summary>
    /// <typeparam name="T">Type of entity</typeparam>
    public interface IRepository<T>
    {
        /// <summary>
        /// Gets the by id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns>Entity by id.</returns>
        T GetById(int id);

        /// <summary>
        /// Adds the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        void Save(T entity);

        /// <summary>
        /// Removes the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        void Remove(T entity);

        /// <summary>
        /// Alls the query.
        /// </summary>
        /// <returns>Query to get all entities</returns>
        IQueryable<T> AllQuery();
    }
}